import java.util.Hashtable;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;

public class MyMDBClient {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		 QueueConnection cnn = null;
	        QueueSender sender = null;
	        QueueSession session = null;
	        InitialContext ctx;
	        Hashtable ht = new Hashtable();
	        
	        try {
	        	ht.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
	        	ht.put(Context.PROVIDER_URL,"t3://localhost:7001");

	            ctx = new InitialContext(ht);
	            Queue queue = (Queue) ctx.lookup("RBKQueue");
	            QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup("RBKConnectionFactory");
	            cnn = factory.createQueueConnection();
	            session = cnn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
	            TextMessage msg = session.createTextMessage();
	            msg.setText("helloworld");
	            sender = session.createSender(queue);
	            sender.send(msg);
	       
	            System.out.println("Message sent successfully to remote queue.");
	            session.close(); // this is important.
	        } catch (Exception e) {
	            e.printStackTrace();
	        }
	}
}
